package com.qianyu.api.controller.back.usermag;

import com.qianyu.core.entity.base.Result;
import com.qianyu.core.entity.bean.WalletAccount;
import com.qianyu.core.entity.dto.WalletAccountDto;
import com.qianyu.core.service.WalletAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "后台管理-收款账号管理", description = "wangzhicheng")
@RestController
@RequestMapping("/api/walletAccount")
@RequiredArgsConstructor
public class WalletAccountController {

    private final WalletAccountService walletAccountService;

    /**
     * 新增账户信息
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增账户信息")
    Result<String> saveWalletAccount(@RequestBody @Validated WalletAccountDto.WalletAccountSaveDto dto) {
        walletAccountService.saveWalletAccount(dto);
        return Result.success();
    }

    /**
     * 编辑账户信息
     */
    @PostMapping("/edit")
    @ApiOperation(value = "编辑账户信息")
    Result<String> editWalletAccount(WalletAccountDto.WalletAccountEditDto dto) {
        walletAccountService.editWalletAccount(dto);
        return Result.success();
    }

    /**
     * 查询账户信息
     */
    @GetMapping("/get")
    @ApiOperation(value = "查询账户信息")
    Result<WalletAccount> getAccount() {
        return Result.success(walletAccountService.getAccount());
    }
}
